﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace OliveChess
{
    class IterativePosStackItem
    {
        public IterativePosStackItem(Position pos)
        {
            //position = pos;
            moves = new List<Move>();
            Engine.GetLegalMoves(ref pos, ref moves);
            index = 0;
        }

        //public Position position; //no need
        public List<Move> moves;
        private int index;
        //private Position pos;

        public void Begin(){
            index = 0; 
        }

        public bool End(){
            return (index >= moves.Count); 
        }

        public void Next(){
            index++; 
        }

        public Move GetMove(){
            Debug.Assert((index >= 0) && (index < moves.Count));
            return moves[index]; 
        }
    }
}
